import vue from '@vitejs/plugin-vue';
import path from 'path';
import AutoImport from 'unplugin-auto-import/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';

// https://vite.dev/config/
export default defineConfig({
  // base: '/[app-directory-name]/',
  build: {
    chunkSizeWarningLimit: 2048,
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    dedupe: ['pinia'], // Solving using store from lib project causes runtime error in release build: Cannot read properties of undefined (reading '_s')
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  optimizeDeps: {
    include: ['my-vue-ui-core'],
  },
  server: {
    proxy: {
      '/family-expense/api': 'http://localhost:8088',
    },
  },
});
